<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>缤格</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/swiper.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/binge.css"/>
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/swiper.min.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>
    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
</head>

<body>
<!-- index-header -->
<div id="header" style="height: 1.66rem; background: #fff; position: fixed; top: 0;left: 0; width: 100%; z-index: 999">
    <div class="index-header">
        <!--<div class="logo">
            <img src="../../image/icon-logo1.png" alt="">
        </div>-->
        <div class="search" tapmode onclick="commonUrl('search')">搜索用户、帖子、新闻...</div>
        <div class="icon-msg">
            <a href="javascript:void(0);" tapmode onclick="commonUrl('../member/msg')" class="msg-btn"><span
                    id="msgPoint" style="display: none;"></span></a>
        </div>
    </div>
    <!-- index-dynamic -->
    <div class="index-dynamic bg-fff" id="tab-list">
        <ul id="navList" class="">
            <!--<li class="on "><a href="javascript:void(0);">头条</a></li>-->
            <!--<li class=""><a href="javascript:void(0);">热门</a></li>-->
            <!--<li class=""><a href="javascript:void(0);">考研</a></li>-->
            <!--<li class=""><a href="javascript:void(0);">比赛</a></li>-->
            <!--<li class=""><a href="javascript:void(0);">论文</a></li>-->
            <!--<li class=""><a href="javascript:void(0);">985/211</a></li>-->
            <!--<li class=""><a href="javascript:void(0);">比赛</a></li>-->
            <!--<li class=""><a href="javascript:void(0);">论文</a></li>-->
            <!--<li class=""><a href="javascript:void(0);">985/211</a></li>-->
        </ul>
    </div>
    <!-- index-dynamic end -->
</div>
<!-- index-header end -->


<!-- index-main -->
<div class="index-main mescroll" id="mescroll" style="padding-top: 2.4rem;">

    <div class="section" data-load="true" data-page="1">
        <div class="main-banner swiper-container" style="display: none">
            <ul class="swiper-wrapper" id="banner">
                <!--<li class="swiper-slide">
                    <a href="##" tapmode onclick="commonUrl('news_detail')">
                        <img src="../../image/banner01.png" alt="">
                        <div class="swiper-info">
                            <p class="single-ellipsis">国庆阅兵仪式，中国军人最美的...</p>
                        </div>
                    </a>
                </li>
                <li class="swiper-slide">
                    <a href="##" tapmode onclick="commonUrl('news_detail')">
                        <img src="../../image/banner01.png" alt="">
                        <div class="swiper-info">
                            <p class="single-ellipsis">国庆阅兵仪式，中国军人最美的...</p>
                        </div>
                    </a>
                </li>-->
            </ul>
            <div class="swiper-pagination"></div>
        </div>
        <div class="index-match" id="match" style="display: none;">
            <!--<ul class="kinds-1">
                <li tapmode onclick="commonUrl()">
                    <div class="match-li-1">
                        <div class="match-school">
                            <div class="match-school-logo"><img src="../../image/school-logo01.png" alt=""></div>
                            <p class="school-name">澳门大学</p>
                        </div>
                        <div class="match-detail">
                            <h6 class="match-title multiline-ellipsis">足球杯1/8决赛</h6>
                            <p class="match-place single-ellipsis">广州中心体育馆</p>
                            <div class="match-num">12 - 14</div>
                            <span class="play-status status1"></span>
                        </div>
                        <div class="match-school">
                            <div class="match-school-logo"><img src="../../image/school-logo01.png" alt=""></div>
                            <p class="school-name">东南大学</p>
                        </div>
                    </div>
                </li>
                <li tapmode onclick="commonUrl()">
                    <div class="match-li-2">
                        <div class="match-school-logo"><img src="../../image/school-logo01.png" alt=""></div>
                        <div class="match-detail">
                            <h6>全国大学生舞蹈大赛</h6>
                            <p class="single-ellipsis">2019.12.31 北京艺术学院...</p>
                        </div>
                        <div class="play-status status1"></div>
                    </div>
                </li>
            </ul>
            <ul class="kinds-2">

                <li tapmode onclick="commonUrl()">
                    <div class="match-li-3">
                        <div class="match-title">
                            <h6 class="single-ellipsis">足球杯1/8决赛</h6>
                            <span class="play-status status1"></span>
                        </div>
                        <p class="match-addr single-ellipsis">广州中心体育馆</p>
                        <div class="match-detail">
                            <div class="match-school">
                                <div class="match-school-logo"><img src="../../image/school-logo01.png" alt=""></div>
                                <p class="school-name single-ellipsis">澳门大学</p>
                            </div>
                            <div class="match-num">122 - 142</div>
                            <div class="match-school">
                                <div class="match-school-logo"><img src="../../image/school-logo01.png" alt=""></div>
                                <p class="school-name single-ellipsis">澳门大学</p>
                            </div>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="match-li-3">
                        <div class="match-title">
                            <h6 class="single-ellipsis">足球杯1/8决赛</h6>
                            <span class="play-status status2"></span>
                        </div>
                        <p class="match-addr single-ellipsis">广州中心体育馆</p>
                        <div class="match-detail">
                            <div class="match-school">
                                <div class="match-school-logo"><img src="../../image/school-logo01.png" alt=""></div>
                                <p class="school-name single-ellipsis">澳门大学</p>
                            </div>
                            <div class="match-num no-start">今天 13:00</div>
                            <div class="match-school">
                                <div class="match-school-logo"><img src="../../image/school-logo01.png" alt=""></div>
                                <p class="school-name ">澳门大学澳门大</p>
                            </div>
                        </div>
                    </div>
                </li>
            </ul>-->
        </div>

        <div class="index-today" style="display: none;">
            <div class="today-title">
                <h6><b id="ifToday">往</b>日话题</h6>
                <a href="javascript:void(0);" tapmode onclick="commonUrl('topic_before_list')"
                   class="more-topic">更多话题></a>
            </div>
            <div class="topic-list">
                <ul id="discuss">
                    <!--<li tapmode onclick="commonUrl('topic_detail')">
                        <h6 class="topic-title single-ellipsis">压力是否越大越好压力？</h6>
                        <p class="topic-num">22456人已参与</p>
                        <div class="topic-vote" style="display: none;">
                            <span class="vote choose1" tapmode onclick="choose(1,event)">学历</span>
                            <span class="vote choose2" tapmode onclick="choose(2,event)">经历</span>
                        </div>
                        <div class="choose-result" style="display: block;">
                            <div class="result1 result">
                                <div class="result-txt"><span class="icon">学历学历学历</span></div>
                                <div class="bar-line">
                                    <div class="line" style="width: 70%;"></div>
                                </div>
                                <div class="percentage">70%</div>
                            </div>
                            <div class="result2 result">
                                <div class="result-txt"><span class="icon">学历学历</span></div>
                                <div class="bar-line">
                                    <div class="line" style="width: 30%;"></div>
                                </div>
                                <div class="percentage">30%</div>
                            </div>
                        </div>
                    </li>-->
                </ul>
            </div>
        </div>

        <div class="indexContent">

        </div>
    </div>

</div>

<!-- index-main end -->


<!-- 底部导航 -->
<div id="footer" class="border-t">
    <ul class="flex-wrap">
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con active">首页</li>
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">圈子</li>
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">
            <div class="school-logo">
                <img id="school_path" src="" alt="">
            </div>
        </li>
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">赛事</li>
        <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">我的</li>
    </ul>
</div>


</body>

</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<link rel="stylesheet" type="text/css" href="../../css/mescroll.min.css"/>
<script type="text/javascript" src="../../script/mescroll.min.js"></script>
<script type="text/javascript">

    var category_id = 46;//首页导航id
    var page = 1;//页码
    var pullUp = true;
    var navIndex = 0;
    apiready = function () {

        setFixStatusBar(); //设置状态栏

        var arr = ['index'];
        $api.setStorage('beforePath',arr);
        console.log(jsonChange($api.getStorage('beforePath')))

        pop.loading()
        //监听返回键
        // tabNavListener();

        ExitApp()

        //监听消息
        api.addEventListener({
            name: 'msgStatus'
        }, function (ret, err) {
            page = 1
            getIndexInfo()
        });

        api.addEventListener({
            name: 'topiclist'
        }, function (ret, err) {
            page = 1
            getIndexInfo()
        });

        api.addEventListener({
            name: 'shield'
        }, function (ret, err) {
            page = 1;
            getIndexInfo()
        });

        //刷新监听
        api.addEventListener({
            name: 'refresh'
        }, function (ret, err) {
            page = 1;
            getIndexInfo()
        });

        $('#school_path').attr('src', $api.getStorage('schoolPath'));
        api.addEventListener({
            name: 'schoolPathStatus'
        }, function (ret, err) {
            $('#school_path').attr('src', $api.getStorage('schoolPath'));
        });

        //获取首页导航栏
        get_nav();

        getMemberInfo();


        SystemCheckVersion()

        // ajpush()

        version();//版本检测，下载更新

    }

    function getMemberInfo() {
        var param = {
            token: $api.getStorage('token')
        }
        getAjax(Interface.memberIndex, param, function (res) {
            var data = res.data;
            $api.setStorage('userInfo', data);
        }, function (error) {

        });
    }

    //获取首页导航栏
    function get_nav() {

        getAjax(Interface.get_nav, '', function (res) {
            var html = '';
            var list = res.data;
            var section_li = '';
            if (isDefine(list)) {
                for (var i = 0; i < list.length; i++) {
                    if (i == 0) {
                        category_id = list[i].id;
                        html += '<li class="on" data-id="' + list[i].id + '"><a href="javascript:void(0);">' + list[i].title + '</a></li>';
                    } else {
                        html += '<li data-id="' + list[i].id + '"><a href="javascript:void(0);">' + list[i].title + '</a></li>';
                    }
                    if (i < (list.length - 1)) {
                        section_li += '<div class="section" style="display: none;" data-load="false"><div class="indexContent"></div></div>'
                    }
                }
                $('#navList').html(html);
                $('.index-main .section').eq(0).after(section_li);
                //获取首页信息
                getIndexInfo();
            }
        }, function (error) {
            pop.notice(error.msg);
        })
    }


    //获取首页信息
    function getIndexInfo() {
        var param = {
            token: $api.getStorage('token'),
            category_id: category_id,
            page: page,
        }

        getAjax(Interface.index, param, function (res) {
            var banner = res.data.banner;
            //消息提示
            if (res.data.notice_num == 0) {
                $('#msgPoint').hide()
            } else {
                $('#msgPoint').show()
            }

            if (isDefine(banner)) {

                var bannerHtml = '';//banner图
                for (var i = 0; i < banner.length; i++) {

                    if(isDefine(banner[i].icon_path)){
                        if(isDefine(banner[i].icon_path[0]) && banner[i].icon_path[0] !=""){
                            bannerHtml += '<li class="swiper-slide">' +
                                '                <a href="javascript:void(0);" class="bg-cover" style="background: url(' + ajaxUrl + banner[i].icon_path[0] + ')" onclick=\'toUrl("' + banner[i].url + '",' + banner[i].id + ')\' tapmode data-id="' + banner[i].id + '">' +
                                // '                    <img src="' +  + '" alt="">' +
                                '                    <div class="swiper-info">' +
                                '                        <p class="single-ellipsis">' + banner[i].title + '</p>' +
                                '                    </div>' +
                                '                </a>' +
                                '            </li>';
                        }
                    }else {
                        bannerHtml += '<li class="swiper-slide">' +
                            '                <a href="javascript:void(0);" class="bg-cover" style="background: url(' + ajaxUrl + banner[i].void_icon_path + ')" onclick=\'toUrl("' + banner[i].url + '",' + banner[i].id + ')\' tapmode data-id="' + banner[i].id + '">' +
                            // '                    <img src="' +  + '" alt="">' +
                            '                    <div class="swiper-info">' +
                            '                        <p class="single-ellipsis">' + banner[i].title + '</p>' +
                            '                    </div>' +
                            '                </a>' +
                            '            </li>';
                    }

                }
                $(".main-banner").show().find('#banner').html(bannerHtml);
                swiper.updateSlidesSize()
                swiper.reLoop()

            } else {
                if(navIndex == 0){
                    $(".main-banner").hide();
                }

            }
            var discuss = res.data.discuss;
            var discussHtml = '';//今日话题
            if (isDefine(discuss)) {
                if (discuss.discuss_status == 1){
                    $("#ifToday").html(discuss.day_status)
                    var result;
                    var param = {"discuss_id": discuss.id, "today": 1};
                    var over_time = '未知';
                    if(isDefine(discuss.over_time)){
                        over_time = discuss.over_time;
                    }
                    if (isDefine(discuss.so)) {
                        if (discuss.so == 1) {
                            result = '<div class="choose-result" style="display: block;"><div class="result1 result">' +
                                '                    <div class="result-txt"><span class="icon">' + discuss.just_title + '</span></div>' +
                                '                    <div class="bar-line">' +
                                '                         <div class="line" style="width: ' + discuss.rate + '%; background: #7dcec8"></div>' +
                                '                    </div>' +
                                '                    <div class="percentage" style="color: #7dcec8">' + discuss.rate + '%</div>' +
                                '</div></div>';
                        } else {
                            result = '<div class="choose-result" style="display: block;"><div class="result2 result">' +
                                '                    <div class="result-txt"><span class="icon">' + discuss.back_title + '</span></div>' +
                                '                    <div class="bar-line">' +
                                '                         <div class="line" style="width: ' + discuss.rate + '%; background: #fe7678"></div>' +
                                '                    </div>' +
                                '                    <div class="percentage" style="color: #fe7678">' + discuss.rate + '%</div>' +
                                '</div></div>';
                        }
                        discussHtml = '<li class="mt10 mb20" tapmode onclick=\'commonUrl("topic_detail",' + jsonChange(param) + ')\'>' +
                            '                    <h6 class="topic-title multiline-ellipsis">' + discuss.title + '</h6>' +
                            '                    <p class="topic-num">' + discuss.count + '人已参与 <span>截止时间：'+over_time+'</span></p>' + result + '</li>'
                    } else {
                        discussHtml = '<li class="mt10 mb20" tapmode onclick=\'commonUrl("topic_detail",' + jsonChange(param) + ')\'>' +
                            '                    <h6 class="topic-title multiline-ellipsis">' + discuss.title + '</h6>' +
                            '                    <p class="topic-num">' + discuss.count + '人已参与 <span>截止时间：'+over_time+'</span></p>' +
                            '                    <div class="topic-vote" data-num="' + discuss.count + '">' +
                            '                        <span class="vote choose1" tapmode onclick="choose(' + discuss.id + ',1,event,this)">' + discuss.just_title + '</span>' +
                            '                        <span class="vote choose2" tapmode onclick="choose(' + discuss.id + ',0,event,this)">' + discuss.back_title + '</span>' +
                            '                    </div>' +
                            '                    <div class="choose-result">' +
                            '                        <div class="result1 result">' +
                            '                            <div class="result-txt"><span class="icon">' + discuss.just_title + '</span></div>' +
                            '                            <div class="bar-line">' +
                            '                                <div class="line" style="width: ' + discuss.rate + '%; background: #7dcec8"></div>' +
                            '                            </div>' +
                            '                            <div class="percentage" style="color: #7dcec8">' + discuss.rate + '%</div>' +
                            '                        </div>' +
                            '                        <div class="result2 result">' +
                            '                            <div class="result-txt"><span class="icon">' + discuss.back_title + '</span></div>' +
                            '                            <div class="bar-line">' +
                            '                                <div class="line" style="width: ' + discuss.rate + '%; background: #fe7678"></div>' +
                            '                            </div>' +
                            '                            <div class="percentage" style="color: #fe7678">' + discuss.rate + '%</div>' +
                            '                        </div>' +
                            '                    </div></li>'
                    }
                    $(".index-today").show().find("#discuss").html(discussHtml);
                } else {

                    $(".index-today").show().find("#discussStatus").hide();

                }

            } else {
                if(navIndex == 0){
                    $(".index-today").hide()
                }
            }
            var list = res.data.list;
            if (isDefine(list)) {
                var listHtml = '';
                for (var i = 0; i < list.length; i++) {
                    //leixing： 1为新闻，2为帖子，3为活动, 5为投票

                    if (list[i].leixing == 1 || list[i].leixing == 4) {

                        listHtml += getNewsText(list[i].data,list[i].leixing,category_id);

                    } else if (list[i].leixing == 2) {

                        listHtml += getInviteText(list[i].data);


                    } else if (list[i].leixing == 3) {

                        listHtml += getActivityText(list[i].data);


                    } else if(list[i].leixing == 5){

                        var html = getVoteText(list[i].data);

                        listHtml += '<div class="index-news"><ul>'+html+'</ul></div>'

                    }

                }
                if (page == 1) {
                    page++;
                    $('.index-main .section').eq(navIndex).find('.indexContent').html(listHtml).attr({'data-page':page,'data-load': 'true'});
                } else {
                    page++;

                    $('.index-main .section').eq(navIndex).find('.indexContent').append(listHtml).attr({'data-page':page,'data-load': 'true'});
                }
                pullUp = true;
                switchController()

            } else {
                if (page == 1) {
                    $('.index-main .section').eq(navIndex).find('.indexContent').html(noData).attr({'data-page':page,'data-load': 'true'});
                } else {
                    $('.index-main .section').eq(navIndex).find('.indexContent').append('<p style="width: 100%;" class="pt30 t-c c-999">没有更多了</p>').attr({'data-page':page,'data-load': 'true'});
                }
                pullUp = false;

            }

            if (isDefine(res.data.match)) {
                var match = res.data.match.data;
                if (isDefine(match)) {
                    var matchType = res.data.match.match_type;
                    var matchHtml = '';
                    $.each(match, function (i, item) {
                        var matchData = item.data;
                        if (matchType == 1) {

                            var team1 = matchData.data[0];
                            var team2 = matchData.data[1];

                            var matchParam = {'match_id': matchData.id}

                            var url = '';
                            //type 1是篮球，2是足球
                            if (matchData.type == 1) {
                                url = '../match/match_basketball';
                            } else {
                                url = '../match/match_football';
                            }
                            if (team1.branch == '') {
                                team1.branch = 0;
                            }


                            if (team2.branch == '') {
                                team2.branch = 0;
                            }

                            var sHtml = '';
                            var mHtml = '';
                            if (matchData.status == 1) {
                                sHtml = '<div class="match-title"><h6 class="single-ellipsis">' + matchData.title + '</h6><span class="play-status status1">未开始</span></div>';
                                mHtml = '<div class="match-num no-start">' + matchData.start_date + '</div>';
                            } else if (matchData.status == 2) {
                                sHtml = '<div class="match-title"><h6 class="single-ellipsis">' + matchData.title + '</h6><span class="play-status status2">进行中</span></div>';
                                mHtml = '<div class="match-num">' + team1.branch + ' - ' + team2.branch + '</div>'
                            } else if (matchData.status == 3) {
                                sHtml = '<div class="match-title"><h6 class="single-ellipsis">' + matchData.title + '</h6><span class="play-status status3">已结束</span></div>';
                                mHtml = '<div class="match-num">' + team1.branch + ' - ' + team2.branch + '</div>'
                            } else if (matchData.status == 4) {
                                sHtml = '<div class="match-title"><h6 class="single-ellipsis">' + matchData.title + '</h6><span class="play-status status4">直播中</span></div>';
                                mHtml = '<div class="match-num">' + team1.branch + ' - ' + team2.branch + '</div>'
                            } else if (matchData.status == 5) {
                                sHtml = '<div class="match-title"><h6 class="single-ellipsis">' + matchData.title + '</h6><span class="play-status status5">视频回放</span></div>';
                                mHtml = '<div class="match-num">' + team1.branch + ' - ' + team2.branch + '</div>'
                            }

                            matchHtml += '<li tapmode onclick=\'commonUrl("' + url + '",' + jsonChange(matchParam) + ')\'>' +
                                '                <div class="match-li-3">' + sHtml +
                                '                    <p class="match-addr single-ellipsis">' + matchData.address + '</p>' +
                                '                    <div class="match-detail">' +
                                '                        <div class="match-school">' +
                                '                            <div class="match-school-logo"><img imgurl="'+ ajaxUrl + team1.team_path +'" src="" alt=""></div>' +
                                '                            <p class="school-name ">' + team1.team_title + '</p>' +
                                '                        </div>' + mHtml +
                                '                        <div class="match-school">' +
                                '                            <div class="match-school-logo"><img imgurl="'+ ajaxUrl + team2.team_path +'" src="" alt=""></div>' +
                                '                            <p class="school-name ">' + team2.team_title + '</p>' +
                                '                        </div>' +
                                '                    </div>' +
                                '                </div>' +
                                '            </li>';

                        } else {


                            if (item.leixing == 1) {

                                var matchData = item.data;
                                var team1 = matchData.data[0];
                                var team2 = matchData.data[1];

                                var matchParam = {'match_id': matchData.id}

                                var url = '';
                                //type 1是篮球，2是足球
                                if (matchData.type == 1) {
                                    url = '../match/match_basketball';
                                } else {
                                    url = '../match/match_football';
                                }
                                if (team1.branch == '') {
                                    team1.branch = 0;
                                }
                                if (team2.branch == '') {
                                    team2.branch = 0;
                                }

                                var mHtml = '';
                                var mScroe = '';

                                if (matchData.status == 1) {
                                    mHtml = '<span class="play-status status1">未开始</span>';
                                    mScroe = '<p style="font-size: 0.32rem;">' + matchData.start_date+'</p>';
                                } else if (matchData.status == 2) {
                                    mHtml = '<span class="play-status status2">进行中</span>';
                                    mScroe = team1.branch + ' - ' + team2.branch;
                                } else if (matchData.status == 3) {
                                    mHtml = '<span class="play-status status3">已结束</span>';
                                    mScroe = team1.branch + ' - ' + team2.branch;
                                } else if (matchData.status == 4) {
                                    mHtml = '<span class="play-status status4">直播中</span>';
                                    mScroe = team1.branch + ' - ' + team2.branch;
                                } else if (matchData.status == 5) {
                                    mHtml = '<span class="play-status status5">视频回放</span>';
                                    mScroe = team1.branch + ' - ' + team2.branch;
                                }

                                matchHtml += '<li>' +
                                    '                <div class="match-li-1" tapmode onclick=\'commonUrl("' + url + '",' + jsonChange(matchParam) + ')\'>' +
                                    '                    <div class="match-school">' +
                                    '                        <div class="match-school-logo"><img imgurl="'+ ajaxUrl + team1.team_path +'" src="" alt=""></div>' +
                                    '                        <p class="school-name">' + team1.team_title + '</p>' +
                                    '                    </div>' +
                                    '                    <div class="match-detail">' +
                                    '                        <h6 class="match-title multiline-ellipsis">' + matchData.title + '</h6>' +
                                    '                        <p class="match-place single-ellipsis">' + matchData.address + '</p>' +
                                    '                        <div class="match-num">' + mScroe + '</div>' + mHtml +
                                    '                    </div>' +
                                    '                    <div class="match-school">' +
                                    '                        <div class="match-school-logo"><img imgurl="'+ ajaxUrl + team2.team_path +'" src="" alt=""></div>' +
                                    '                        <p class="school-name">' + team2.team_title + '</p>' +
                                    '                    </div>' +
                                    '                </div>' +
                                    '            </li>';

                            } else {

                                var matchParam = {'match_id': matchData.id}
                                var sHtml = '';
                                if (matchData.status == 1) {
                                    sHtml = ' <div class="play-status status1">未开始</div>';
                                } else if (matchData.status == 2) {
                                    sHtml = ' <div class="play-status status2">进行中</div>';
                                } else if (matchData.status == 3) {
                                    sHtml = ' <div class="play-status status3">已结束</div>';
                                } else if (matchData.status == 4) {
                                    sHtml = ' <div class="play-status status4">直播中</div>';
                                } else if (matchData.status == 5) {
                                    sHtml = ' <div class="play-status status5">视频回放</div>';
                                }

                                matchHtml += '<li>' +
                                    '                <div class="match-li-2" tapmode onclick=\'commonUrl("../match/team_match_detail",' + jsonChange(matchParam) + ')\'>' +
                                    '                    <div class="match-school-logo"><img imgurl="'+ ajaxUrl + matchData.icon_path +'" src="" alt=""></div>' +
                                    '                    <div class="match-detail">' +
                                    '                        <h6>' + matchData.title + '</h6>' +
                                    '                        <p class="single-ellipsis">'+matchData.start_day+' ' + matchData.address + '</p>' +
                                    '                    </div>' + sHtml +
                                    '                </div>' +
                                    '            </li>'

                            }

                        }

                    })
                    var matchHtml_end = '';
                    if (matchType == 1) {
                        matchHtml_end = '<ul class="kinds-2">' + matchHtml + '</ul>';
                    } else {
                        matchHtml_end = '<ul class="kinds-1">' + matchHtml + '</ul>';
                    }
                    $("#match").show().html(matchHtml_end);
                } else {
                    if(navIndex == 0){
                        $("#match").hide();
                    }
                }

            } else {
                if(navIndex == 0){
                    $("#match").hide();
                }
            }

            pop.close();

            mescroll.endErr();

            mescroll.lazyLoad();//图片懒加载，数据加载之后使当前可视区域的图片显示出来
        }, function (error) {
            pop.notice(error.msg);
            pop.close();
            mescroll.endErr();

        })
    }



    //关注、取消关注
    function followAction(stype, pid, that) {
        var type = 1;//类型：1会员 2圈子

        var className = '.class' + pid;

        follow(stype, type, pid, function (res) {
            if (stype == 1) {
                pop.notice('关注成功');
                // $(className).addClass('on')
                $(className).remove()
                // $(that).parents('.follow').addClass('on')
            } else {
                pop.notice('已取消关注');
                $(className).removeClass('on')
                // $(that).parents('.follow').removeClass('on')
            }
        })
    }


    //首页导航栏目 tab 切换
    $("#tab-list").on('click', 'li', function () {
        var _this = $(this);
        if(_this.index() == navIndex){
            return;
        }
        navIndex = _this.index();
        var id = _this.attr('data-id');
        page = 1;
        category_id = id;
        _this.addClass('on').siblings('li').removeClass('on');
        $('.index-main .section').eq(navIndex).fadeIn(100).siblings('.section').fadeOut(10);
        var reload = $('.index-main .section').eq(navIndex).find('.indexContent').attr('data-load');
        if(reload){
            return;
        }
        getIndexInfo()

    });


    //今日话题投票
    function choose(discuss_id, type, event, that) {
        event.stopPropagation();
        var _this = that;
        var param = {
            token: $api.getStorage('token'),
            discuss_id: discuss_id,
            type: type,
        }
        getAjax(Interface.discuss_vote, param, function (res) {
            var rate = res.data.rate;
            var topicNum = Number($(_this).parents('.topic-vote').attr('data-num')) + 1;
            if (type == 1) {
                //赞成
                $(_this).parents('.topic-vote').hide().siblings('.choose-result').show().find('.result2').hide();
            } else {
                //反对
                $(_this).parents('.topic-vote').hide().siblings('.choose-result').show().find('.result1').hide();
            }
            $(_this).parents('.topic-vote').siblings('.choose-result').find('.line').css({width: rate + '%'});
            $(_this).parents('.topic-vote').siblings('.choose-result').find('.percentage').html(rate + '%');
            $(_this).parents('.topic-vote').siblings('.topic-num').html(topicNum + '人已参与');
            pop.notice(res.msg)
        }, function (error) {
            pop.notice(error.msg)
        })
    }


    var swiper = new Swiper('.main-banner', {
        autoplay: 5000,
        observer: true,//修改swiper自己或子元素时，自动初始化swiper
        observeParents: true,//修改swiper的父元素时，自动初始化swiper
        pagination: '.main-banner .swiper-pagination',
        loop: true,
        autoplayDisableOnInteraction: false,
    })

    //创建MeScroll对象
    var mescroll = new MeScroll("mescroll", {
        down: {
            auto: false, //是否在初始化完毕之后自动执行下拉回调callback; 默认true
            callback: downCallback //下拉刷新的回调
        },
        up: {
            auto: false, //是否在初始化时以上拉加载的方式自动加载第一页数据; 默认false
            isBounce: true, //此处禁止ios回弹,解析(务必认真阅读,特别是最后一点): http://www.mescroll.com/qa.html#q10// 若为false ,页面上其他地方的滑动都滑不动
            callback: upCallback, //上拉回调,此处可简写; 相当于 callback: function (page) { upCallback(page); }
            /*toTop:{ //配置回到顶部按钮
                src : "../res/img/mescroll-totop.png", //默认滚动到1000px显示,可配置offset修改
                //offset : 1000
            }*/
            lazyLoad: {
                use: true, // 是否开启懒加载,默认false
                attr: 'imgurl', // 网络地址的属性名 (图片加载成功会移除该属性): <img imgurl='网络图  src='占位图''/>
                showClass: 'mescroll-lazy-in', // 图片加载成功的显示动画: 渐变显示,参见mescroll.css
                delay: 200, // 列表滚动的过程中每500ms检查一次图片是否在可视区域,如果在可视区域则加载图片
                offset: 500 // 超出可视区域200px的图片仍可触发懒加载,目的是提前加载部分图片
            }
        }
    });

    /*下拉刷新的回调 */
    function downCallback() {
        page = 1;
        getIndexInfo()
        //mescroll.endErr();
    }

    /*上拉加载的回调 */
    function upCallback() {
        if (pullUp == true) {
            page = $('.index-main .indexContent').eq(navIndex).attr('data-page');
            console.log(page)
            getIndexInfo()
        } else {
            mescroll.endErr();
        }
    }


    function version(){
        //是否第一次进入
        var isOneTree = api.getGlobalData({
            key: 'isOneTree'
        });
        if(!isOneTree){
            api.setGlobalData({
                key: 'isOneTree',value: '1'
            });
            getversion(function(res){
                var sysType = api.systemType;
                if(sysType == 'ios'){
                    if (isDefine(res.data.ios_number)){
                        if(ios_code < res.data.ios_number){
                            api.alert({
                                title: '新版本更新！',
                                buttons:['更新']
                            }, function(ret, err) {
                                if(sysType == 'ios'){
                                    iosDown(res.file);
                                }else if(sysType == 'android'){
                                    anroidDown(res.file);
                                }
                            });
                        }else {

                        }
                    }
                }else if(sysType == 'android'){
                    if (isDefine(res.data.vsersion_code)){
                        if(vsersion_code < res.data.vsersion_code){
                            var data = res.data;
                            if(data.is_gengxin){
                                api.alert({
                                    title: '新版本更新！版本号：'+data.version_name,
                                    msg:'更新内容：'+data.content+';文件大小：'+data.file_size,
                                    buttons:['更新']
                                }, function(ret, err) {
                                    if(sysType == 'ios'){
                                        iosDown(res.file);
                                    }else if(sysType == 'android'){
                                        anroidDown(res.file);
                                    }
                                });
                            }else{
                                api.confirm({
                                    title: '新版本更新！版本号：'+data.version_name,
                                    msg:'更新内容：'+data.content+';文件大小：'+data.file_size,
                                    buttons:['更新','下次更新']
                                }, function(ret, err) {
                                    if(ret.buttonIndex == 1){
                                        if(sysType == 'ios'){
                                            iosDown(res.file);
                                        }else if(sysType == 'android'){
                                            anroidDown(res.file);
                                        }
                                    }

                                });
                            }

                        }
                    }
                }
            })
        }
    }


</script>
